{% extends 'base_with_listing.html' %}

{% block title %}User rentals{% endblock %}

{% block header %}{% if reader %} {{ reader.first_name }} {{ reader.last_name }} {% else %}User rentals{% endif %}{% endblock %}

{% block befor_table %}
    <b>
        {{ first_name }} {{ last_name }}
        <br>
        {{ email|urlize }}
    </b>
    {% block message %}{% endblock %}
{% endblock %}

{% block header_row %}
    {% block return_header %}{% endblock %}
    <th>ID</th>
    <th>Title</th>
    <th>Authors</th>
    <th>From</th>
    <th>To</th>
    <th>Prolongation</th>

{% endblock %}

{% block item_row %}
        {% block return %}{% endblock %}
    <td>
        <b>{{ row.shelf_mark }}</b>
    </td> <td>
        {{ row.title }}
    </td> <td>
        {{ row.authors|join:', ' }}
    </td> <td>
        {{ row.from_date }}
    </td> <td>
        {{ row.to_date }}
    </td> <td>
      <center>
        {% if row.can_request_prolongation %}
            <form action="." method="POST">
               <input type="hidden" name="prolong_rental_id" value="{{ row.id }}">
               <input type="submit" name="prolong_request" value="Prolongation request">
            </form>
        {% endif %}
        {% if row.can_prolong %}
            <form action="." method="POST">
               <input type="hidden" name="prolong_rental_id" value="{{ row.id }}">
               <input type="submit" name="prolong" value="Prolong ({{ row.prolongation_length }} days)">
            </form>
        {% endif %}
        {% if row.cannot_request_nor_prolong %}
            <hr width="50%">
        {% endif %}
      </center>
    </td>
{% endblock %}

{% block after_table %}
    <div class="inner_menu">
      <ul>
        <li><a href='archive/'>Show archival rentals</a></li>
        <li><a href='new/'>Rent something else</a></li>
      </ul>
    </div>
{% endblock %}

